package com.yushealth.prostate.fingerdanceforprostate;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;

import java.util.HashMap;

public class ProfileActivity extends AppCompatActivity {

    TextView profile_level;
    TextView profile_score;
    TextView profile_score_at;
    ProgressBar progressBar;

    final Integer BREATH[] = {5000, 15000, 25000, 35000, 45000, 55000, 65000, 75000, 90000, 100000};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile);

        profile_level = (TextView) findViewById(R.id.profile_level);
        profile_score = (TextView) findViewById(R.id.profile_score);
        profile_score_at = (TextView) findViewById(R.id.profile_score_at);

        progressBar = (ProgressBar) findViewById(R.id.profile_progressbar);

        HashMap<String, Integer> profileData = (HashMap<String, Integer>) getIntent().getSerializableExtra("profile");
        // 计算总息数
        int level = profileData.get("level");
        int score_total = 0;
        for (int i = 0; i < level; i++) {
            score_total += BREATH[i];
        }
        score_total += profileData.get("score");

        // 显示： 进度条
        progressBar.setMax(BREATH[level]);
        progressBar.setProgress(profileData.get("score"));
        // 显示：文本框
        profile_level.setText(String.format("Your level: %s", level));
        profile_score.setText(String.format("Your score: %s", score_total));
        Integer score_left = BREATH[level] - profileData.get("score");
        profile_score_at.setText(String.format("Next level: %s", score_left));

    }
}
